Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
    ''' <summary>
    ''' Controller class for ClubEvent
    ''' </summary>
		<System.ComponentModel.DataObject()> Public Partial Class ClubEventController
    
        ' Preload our schema..
        Dim thisSchemaLoad As ClubEvent = New ClubEvent()
        Private strUserName As String = String.Empty
        Protected ReadOnly Property UserName() As String
            Get
				If strUserName.Length = 0 Then
		        
    				If Not System.Web.HttpContext.Current Is Nothing Then
						strUserName = System.Web.HttpContext.Current.User.Identity.Name
					Else
		        		strUserName = System.Threading.Thread.CurrentPrincipal.Identity.Name
					End If
					Return strUserName
				End If
				Return strUserName
			End Get
        End Property
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchAll() As ClubEventCollection
        
            Dim coll As ClubEventCollection = New ClubEventCollection()
            Dim qry As Query = New Query(ClubEvent.Schema)
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
            
        End Function
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByID(ByVal Id As Object) As ClubEventCollection 
        
            Dim coll As ClubEventCollection = New ClubEventCollection().Where("ID", Id).Load()
            Return coll
        
        End Function
        
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByQuery(ByVal qry As SubSonic.Query) As ClubEventCollection 
        
            Dim coll As ClubEventCollection = New ClubEventCollection()
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, True)> Public Function Delete(ByVal Id As Object) as Boolean
        
            Return (ClubEvent.Delete(Id) = 1)
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, False)> Public Function Destroy(ByVal Id As Object) as Boolean
        
            Return (ClubEvent.Destroy(Id) = 1)
        
        End Function
        
    	
	    ''' <summary>
	    ''' Inserts a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Insert, True)> Public Sub Insert(ByVal Starttime As DateTime,ByVal Endtime As Nullable(Of DateTime),ByVal Title As String,ByVal Description As String,ByVal StaticURL As String,ByVal Photo As Integer,ByVal Album As Nullable(Of Integer),ByVal Rsvp As Boolean,ByVal TotalAttendance As Nullable(Of Integer),ByVal CurrentAttendance As Nullable(Of Integer),ByVal LocationName As String,ByVal LocationDirections As String)
	   
		    Dim item As ClubEvent = New ClubEvent()
		    
            item.Starttime = Starttime
            
            item.Endtime = Endtime
            
            item.Title = Title
            
            item.Description = Description
            
            item.StaticURL = StaticURL
            
            item.Photo = Photo
            
            item.Album = Album
            
            item.Rsvp = Rsvp
            
            item.TotalAttendance = TotalAttendance
            
            item.CurrentAttendance = CurrentAttendance
            
            item.LocationName = LocationName
            
            item.LocationDirections = LocationDirections
            
	    
		    item.Save(UserName)
	   
	   End Sub
    	
	    ''' <summary>
	    ''' Updates a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Update, True)> Public Sub Update(ByVal Id As Integer,ByVal Starttime As DateTime,ByVal Endtime As Nullable(Of DateTime),ByVal Title As String,ByVal Description As String,ByVal StaticURL As String,ByVal Photo As Integer,ByVal Album As Nullable(Of Integer),ByVal Rsvp As Boolean,ByVal TotalAttendance As Nullable(Of Integer),ByVal CurrentAttendance As Nullable(Of Integer),ByVal LocationName As String,ByVal LocationDirections As String)
	    
		    Dim item As ClubEvent = New ClubEvent()
		    
				item.Id = Id
				
				item.Starttime = Starttime
				
				item.Endtime = Endtime
				
				item.Title = Title
				
				item.Description = Description
				
				item.StaticURL = StaticURL
				
				item.Photo = Photo
				
				item.Album = Album
				
				item.Rsvp = Rsvp
				
				item.TotalAttendance = TotalAttendance
				
				item.CurrentAttendance = CurrentAttendance
				
				item.LocationName = LocationName
				
				item.LocationDirections = LocationDirections
				
		    item.MarkOld()
		    item.Save(UserName)
	    
	    End Sub
    End Class
End Namespace
